<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>轮播</title>
    <script src="jQuery/jquery-1.12.4.js"></script>
    <style>
        *{
            margin: 0;
            padding: 0;
            list-style: none;
        }
        .garousel{
            width: 790px;
            height: 340px;
            position: relative;
            margin: 100px auto;
        }
        .uimg,.uimg li{
            position: absolute;
            width: 100%;
            height: 100%;
        }
        .uimg li {
            position: absolute;
            display: none;
        }

        .uimg li:first-child {
            display: block;
        }
        .arrow{

        }
        .left,.right{
            width: 40px;
            height: 60px;
            background-color: cornflowerblue;
            position: absolute;
            color: white;
            font-size: 40px;
            text-align: center;
            line-height: 60px;
            top: 50%;
            margin-top: -30px;
            cursor: pointer;
        }
        .left{
            left: 0;
        }
        .right{
            right: 0;
        }
        .arrow {
            display: none;
        }

        .garousel:hover .arrow {
            display: block;
        }
    </style>
</head>
<body>
<div class="garousel">
    <ul class="uimg">
        <li><img src="jdlunbo-imgs/1.jpg" alt=""></li>
        <li><img src="jdlunbo-imgs/2.jpg" alt=""></li>
        <li><img src="jdlunbo-imgs/3.jpg" alt=""></li>
        <li><img src="jdlunbo-imgs/4.jpg" alt=""></li>
        <li><img src="jdlunbo-imgs/5.jpg" alt=""></li>
        <li><img src="jdlunbo-imgs/6.jpg" alt=""></li>
        <li><img src="jdlunbo-imgs/7.jpg" alt=""></li>
        <li><img src="jdlunbo-imgs/8.jpg" alt=""></li>
    </ul>
    <div class="arrow">
        <span class="left"><</span>
        <span class="right">></span>
    </div>
</div>
<script>
    $(function () {
        var i=0;//用来标记click到第几下，再转化到相对应的图片
        $(".left").click(function () {
           i--;//向左减少值
            if(i == -1){
                i = $(".uimg li").length - 1;//第一张图片再减1就要重置到最后一张图片的数字8
            }
            $(".uimg li").eq(i).fadeIn().siblings("li").fadeOut();
        })
        $(".right").click(function () {
            i++;//向右增大值
            if(i ==$(".slider li").length){//如果i到了最后一张图片i就要重新开始
                i=0;
            }
            $(".uimg li").eq(i).fadeIn().siblings("li").fadeOut();
        })
    })
</script>
</body>
</html>